import Vue from 'vue'
import VueRouter from 'vue-router'
import Login from '../views/Login.vue'

Vue.use(VueRouter)

// 处理多次请求同一个路径报错的问题
let originalPush = VueRouter.prototype.push;
VueRouter.prototype.push = function(location){
  return originalPush.call(this,location).catch(err=>err)
}

const routes = [
  {
    path: '/',
    name: 'Login',
    component: Login
  },
  {
    path: '/dashboard',
    name: 'dashboard',
    component: () => import('@/components/Dashboard.vue'),
    children:[
      {
        path:'',
        name:'home',
        component: () => import("@/components/Home.vue")
      },
      {
        path:'/addtag',
        name:'addtag',
        component: () => import("@/components/AddTag.vue"),
        meta:["标签管理","添加标签"]
      },
      {
        path:'/taglist',
        name:'taglist',
        component: () => import("@/components/TagList.vue"),
        meta:["标签管理","标签列表"]
      },
      {
        path:'/addmovie',
        name:'addmovie',
        component: () => import("@/components/AddMovie.vue"),
        meta:["电影管理","添加电影"]
      },
      {
        path:'/movielist',
        name:'movielist',
        component: () => import("@/components/MovieList.vue"),
        meta:["电影管理","微电影管理列表"]
      },
      {
        path:'/addprevue',
        name:'addprevue',
        component: () => import("@/components/AddPrevue.vue"),
        meta:["预告管理","添加预告"]
      },
      {
        path:'/prevuelist',
        name:'prevuelist',
        component: () => import("@/components/PrevueList.vue"),
        meta:["预告管理","预告列表"]
      },
      {
        path:'/menbermanage',
        name:'menbermanage',
        component: () => import("@/components/MenberManage.vue"),
        meta:["会员管理"]
      },
      {
        path:'/remarkmanage',
        name:'remarkmanage',
        component: () => import("@/components/RemarkManage.vue"),
        meta:["评论管理"]
      },
      {
        path:'/collectmanage',
        name:'collectmanage',
        component: () => import("@/components/CollectManage.vue"),
        meta:["收藏管理"]
      },
    ]
  }
]

const router = new VueRouter({
  mode:"history",
  routes
})

export default router
